package xuexi;
abstract class Action{
    public static final int EAT=1;
    public static final int SLEEP=5;
    public static final int WORK=10;
    public void command(int code){
        switch (code){
            case EAT: {
                this.eat();
                break;
            }
            case SLEEP:{
                this.sleep();
                break;
            }
            case WORK:{
                this.work();
                break;
            }
            case EAT+SLEEP+WORK:{
                this.eat();
                this.sleep();
                this.work();
                break;
            }
            default:
        }
    }
    public abstract void eat();
    public abstract void sleep();
    public abstract void work();
}
class Robot extends Action{
    @Override
    public void eat() {
        System.out.println("机器人通过充电补充能量！");
    }

    @Override
    public void sleep() {

    }

    @Override
    public void work() {
        System.out.println("机器人消耗能量来进行无差别工作！");
    }
}
class Person1 extends Action{
    @Override
    public void eat() {
        System.out.println("人坐在桌子上面吃饭！");
    }

    @Override
    public void sleep() {
        System.out.println("人在大圆床睡觉！");
    }

    @Override
    public void work() {
        System.out.println("机器人通过充电补充能量！");
    }
}
class Pig extends Action{

    @Override
    public void eat() {
        System.out.println("猪吃猪饲料或剩饭剩菜！");
    }

    @Override
    public void sleep() {
        System.out.println("猪睡在潮湿脏乎乎的猪栏！");
    }

    @Override
    public void work() {

    }
}
public class abstractClass {
    public static void main(String[] args){
        Action actionRobot=new Robot();
        Action actionPerson=new Person1();
        Action actionPig=new Pig();
        System.out.println("-------机器人的操作-------");
        actionRobot.command(Action.EAT);
        actionRobot.command(Action.SLEEP);
        actionRobot.command(Action.WORK);
        System.out.println("-------人类的操作-------");
        actionPerson.command(Action.EAT);
        actionPerson.command(Action.SLEEP);
        actionPerson.command(Action.WORK);
        System.out.println("-------猪的操作-------");
        actionPig.command(Action.EAT);
        actionPig.command(Action.SLEEP);
        actionPig.command(Action.WORK);
    }
}
